<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Menu
{
	function setVars()
	{
        
		$this->menu = array(
            '1' => anchor('', 'Lobby',array('class'=>'MainMenu','title'=>'Start Page')),
            '2' => anchor('news/article', 'Press',array('class'=>'MainMenu','title'=>'Start Page')),
            '10' => anchor('concept', 'Concept',array('class'=>'MainMenu','title'=>'Information about Mobile Billboards')),
			'20' => anchor('services', 'Services',array('class'=>'MainMenu','title'=>'PzzAzz Services')),
            '21' => anchor('locations','Locations',array('class'=>'MainMenu','title'=>'Service areas, Zones and Routes')),
            //'30' => anchor('gallery', 'Gallery',array('class'=>'MainMenu','title'=>'Image Gallery')),
			'30' => anchor('dbview/pages/slideshow', 'Photos',array('class'=>'MainMenu','title'=>'Slideshow')),
            '40' => anchor('dbview/pages/calendar', 'Calendar',array('class'=>'MainMenu','title'=>'PzzAzz Event Calendar')),
            '99' => anchor('dbview/pages/contact_us', 'Contact Us',array('class'=>'MainMenu','title'=>'How to contact us.'))
			);

		$this->sub['news'] = array(
            anchor('news/index','Index',array('class'=>'SubMenu','title'=>'News Archive.'))
            );
        
            $this->sub['services'] = array(
            anchor('services/index','Overview',array('class'=>'SubMenu','title'=>'Servces Overview')),
			anchor('dbview/pages/specs','Specifications',array('class'=>'SubMenu','title'=>'Specifications')),
            anchor('services/quote','Online Quote',array('class'=>'SubMenu','title'=>'Online Quote for Mobile Billboard Adverticing'))
            );

            $this->sub['concept'] = array(
            anchor('concept/index','Overview',array('class'=>'SubMenu','title'=>'Concept Overview')),
            anchor('concept/strategies','Strategies',array('class'=>'SubMenu','title'=>'Ideas for you')),
            anchor('concept/benefits','Benefits',array('class'=>'SubMenu','title'=>'Mobile Adverticing Benefits')),
            anchor('concept/industry','Industry',array('class'=>'SubMenu','title'=>'Industry')),
            anchor('concept/comparison','Comparison',array('class'=>'SubMenu','title'=>'Compered to other media like TV, Radio etc.')),
            anchor('concept/faq','FAQ',array('class'=>'SubMenu','title'=>'Frequently Asked Questions'))
            );
            
        $this->sub['locations'] = array(
            anchor('locations/index','Overview',array('class'=>'SubMenu','title'=>'Service area Overview')),
            anchor('locations/daytona','Daytona',array('class'=>'SubMenu','title'=>'Daytona Beach, Florida')),
            anchor('locations/orlando','Orlando',array('class'=>'SubMenu','title'=>'Orlando, Florida'))
            );
            
            if($this->uid > 0){
                
                $this->menu['90'] = anchor('control_panel', 'My Account',array('class'=>'MainMenu','title'=>'User Control Panel.'));
                $this->sub['control_panel'] = array(
                anchor('control_panel/person','User',array('class'=>'SubMenu','title'=>'Users name and address')),
                anchor('control_panel/company','Comapny',array('class'=>'SubMenu','title'=>'Company name and address')),
                anchor('control_panel/secquestion','Security',array('class'=>'SubMenu','title'=>'Questions for online user verification')),
                anchor('control_panel/control','Settings',array('class'=>'SubMenu','title'=>'Website setting and preferences.')),
                anchor('control_panel/password','Password',array('class'=>'SubMenu','title'=>'Change your login password'))
                );

                $this->menu['93'] = anchor('ticket', 'Support',array('class'=>'MainMenu','title'=>'Online user support'));
                $this->sub['ticket'] = array(anchor('ticket/newTicket','New',array('class'=>'SubMenu','title'=>'Compose a new support ticket')));
                
            }

        if($this->uid == 1){
            
            $this->sub['news'] = array(anchor('news/post','New Post',array('class'=>'SubMenu','title'=>'Post Article')));


            $this->menu[23] = anchor('billboard/roadside', 'Billboard',array('class'=>'MainMenu','title'=>'Roadside Billboards'));
            $this->sub['billboard'] = array(
                anchor('billboard/roadside','Road Side BB',array('class'=>'SubMenu','title'=>'Roadside Billboards')),
                anchor('billboard/bb_vehicle','Vehicle List',array('class'=>'SubMenu','title'=>'Vehicle List')),
                anchor('billboard/bb_vehicle/add','Vehicle Add',array('class'=>'SubMenu','title'=>'Add your Vehicle'))
                );

            $this->menu['29'] = anchor('calendar/event/browse', 'Calendar',array('class'=>'MainMenu','title'=>'Calendar'));
            $this->sub['calendar'] = array(
                anchor('calendar/event/browse',' List Events',array('class'=>'SubMenu','title'=>'List Events')),
                anchor('calendar/event/addedit','Add Event',array('class'=>'SubMenu','title'=>'Add Event'))
                );

            $this->menu['100'] = anchor('admin/', 'Admin',array('class'=>'MainMenu','title'=>'Admin Area'));
            $this->sub['admin'] = array(
                anchor('admin/dbtamer','DB Tamer',array('class'=>'SubMenu','title'=>'DB Tamer')),
                anchor('admin/data','Nested Data',array('class'=>'SubMenu','title'=>'Nested Data')),
                anchor('admin/pages','DB Pages',array('class'=>'SubMenu','title'=>'DB View Pages')),
                anchor('admin/pages/add_edit_page','DB Page Add',array('class'=>'SubMenu','title'=>'DB Page Add')),
                );

            $this->menu['101'] = anchor('test/test', 'Test');
            $this->sub['test'] = array(
                anchor('test/ajaxtest/ajaxdemo','PQuery'),
                anchor('test/orm','ORM'),
                anchor('test/nsd','NSD'),
                anchor('test/sess','Sessions'),
                anchor('test/save','Save')
                );
		}
	}


	
	function Menu()
	{
		log_message('debug', 'Menu: initialized');
	}
	
	function mkMenu()
	{
		$CI =& get_instance();
        $this->uid = $CI->session->userdata('uid');
		$this->setVars();
		ksort($this->menu);
		$segment = $CI->uri->segment(1);
		foreach($this->menu as $k => $v){
			$menu[$k] = $v;
            $v = substr($v, strpos($v,'//')+2,-1);
            $v = rstrstr($v,'" ');
            $v = substr($v, strpos($v,'/')+1,200);
            if (strpos($v,'/') !== FALSE){
            	$v = rstrstr($v,'/');
            }
			if ( ($v == $segment) && isset($this->sub[$segment])){
				$this->menu[$this->menu[$k]] = $this->sub[$segment];
				unset($menu[$k]);
				$menu[$this->menu[$k]] = $this->sub[$segment];
			}
		}
		return $menu;
	}
}
?>
